clear


use "D:\dropbox\Dropbox\James_Ryan_Miriam_\M_RA_ins_active2_5per 1 gvkey_year graph data.dta"
/******************************************************/
/******************************************************/
/* Figure 1                                  */
/******************************************************/
/******************************************************/
foreach var of varlist Nf13 f13 {
tab agecomp , sum(`var'tot)
}


graph set mf fontface  "Times New Roman"


use "F:\Dropbox\Research\James_Ryan_Miriam_\M_RA_ins_active2_5per 1 gvkey_year graph data.dta" 

replace nonf13spreadtot =nonf13spreadtot *100
replace totindex2=totindex2*100
replace individual4tot=individual4tot*100
replace hedge4tot=hedge4tot*100
replace other4tot=other4tot*100
replace fin4tot=fin4tot*100

/******************************************************/
/******************************************************/
/* Figure 2 Panel A                                   */
/******************************************************/
/******************************************************/

rdplot nonf13spreadtot distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 ///
	    & !missing(distancecutoff2) ///
		& nonf13spreadtot<100 ///
		& Nf13tot<0.9 ///
		& year>=2001 ///
		& year<=2014, ///
	p(3) ///
	graph_options( ///
	title(Panel A: Committed blocks,ring(5) position(11) size(medium)) ///
	ytitle("Fraction of shares (%)",size(medlarge) margin(medsmall)) ///
	xtitle(Distance from Russell cutoff,size(medlarge) margin(medsmall)) ///
	legend(off) ///
	ylabel(0(10)45,labsize(med)) ///
	xlabel(-250(50)250,labsize(med)) ///
	scheme(s1mono))
	/*Close the graph options above*/
	/*ci(.95) */
graph export "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure02_A.emf", replace

/******************************************************/
/******************************************************/
/* Figure 2 Panel B                                   */
/******************************************************/
/******************************************************/

rdplot totindex2 distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 ///
	    & !missing(distancecutoff2) ///
		& Nf13tot<.90 ///
		& totindex2<100 ///
		& year>=2001 ///
		& year<=2014, ///
	p(3) ///
	/*ci(99) shade*/    ///
	graph_options( ///
	title(Panel B: Index Funds,ring(5) position(11) size(medium))  ///
	ytitle("Fraction of shares (%)",size(medlarge) margin(medsmall)) ///
	xtitle(Distance from Russell cutoff,size(medlarge) margin(medsmall)) ///
	legend(off) ///
	ylabel(0(10)45,labsize(med)) ///
	xlabel(-250(50)250,labsize(med)) ///
	scheme(s1mono)) ///
	/*Close the graph options above*/
	 ///
graph export "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure02_B.emf", replace

/******************************************************/
/******************************************************/
/* Figure 3 Panel A                                   */
/******************************************************/
/******************************************************/

rdplot individual4tot distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 	///
	& !missing( distancecutoff2 ) 						///	
	& Nf13tot<0.90	 									///
	& individual4tot<100 ///
	& year>=2001 										///
	& year<=2014, 										///
	p(3)  												///
	graph_options(										///
	title(Panel A: Individuals,ring(5) position(11) size(medium))							///
	ytitle("Fraction of shares (%)",size(small) margin(medsmall)) 	///
	xtitle(Distance from Russell cutoff,size(small) margin(medsmall)) 	///
	legend(off) 										///
	ylabel(0(10)40,labsize(small)) 						///
	xlabel(-250(50)250,labsize(small)) 					///
	scheme(s1mono))										///
	
graph save Graph "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_A.gph", replace

rdplot hedge4tot distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 	///
	& !missing( distancecutoff2 ) 						///	
	& Nf13tot<0.90	 	/* I changed this! */			///
	& hedge4tot<100 ///
	& year>=2001 										///
	& year<=2014, 										///
	p(3)  												///
	graph_options(										///
	title(Panel B: Hedge Funds,ring(5) position(11) size(medium))							///
	ytitle("Fraction of shares (%)",size(small) margin(medsmall)) 	///
	xtitle(Distance from Russell cutoff,size(small) margin(medsmall)) 	///
	legend(off) 										///
	ylabel(0(10)40,labsize(small)) 						///
	xlabel(-250(50)250,labsize(small)) 					///
	scheme(s1mono))										///
	
graph save Graph "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_B.gph", replace

rdplot other4tot distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 	///
	& !missing( distancecutoff2 ) 						///	
	& Nf13tot<0.90	 									///
	& other4tot<100 ///
	& year>=2001 										///
	& year<=2014, 										///
	p(3)  												///
	graph_options(										///
	title(Panel C: Other Private,ring(5) position(11) size(medium))						///
	ytitle("Fraction of shares (%)",size(small) margin(medsmall)) 		///
	xtitle(Distance from Russell cutoff,size(small) margin(medsmall)) 	///
	legend(off) 										///
	ylabel(0(10)40,labsize(small)) 						///
	xlabel(-250(50)250,labsize(small)) 					///
	scheme(s1mono))										///
	
graph save Graph "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_C.gph", replace

rdplot fin4tot distancecutoff2 ///
	if  distancecutoff2 <=250 & distancecutoff2 >=-250 	///
	& !missing( distancecutoff2 ) 						///	
	& Nf13tot<0.90 									///
	& fin4tot<100 ///
	& year>=2001 										///
	& year<=2014, 										///
	p(3)  												///
	graph_options(										///
	title(Panel D: 13F Financials,ring(5) position(11) size(medium))						///
	ytitle("Fraction of shares (%)",size(small) margin(medsmall)) 		///
	xtitle(Distance from Russell cutoff,size(small) margin(medsmall)) 	///
	legend(off) 										///
	ylabel(0(10)40,labsize(small)) 						///
	xlabel(-250(50)250,labsize(small)) 					///
	scheme(s1mono))										///
	
graph save Graph "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_D.gph", replace

gr combine 												///
	"F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_A.gph" 	///
	"F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_B.gph"	///
	"F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_C.gph"	///
	"F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_D.gph"	///
	, scheme(s1mono) graphregion(margin(0 0 0 0) color(none) icolor(none) fcolor(none) ifcolor(none) lstyle(none) shadestyle(color(none)) lwidth(none))

graph save Graph "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03_All.gph", replace
graph export "F:\Dropbox\Research\James_Ryan_Miriam_\data\Figures\figure03.emf", replace



